﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class DoiThongTin : System.Web.UI.Page
{
    ThanhVien tv = new ThanhVien();
    protected void Page_Load(object sender, EventArgs e)
    {
        if (IsPostBack != true)
        {
            if (Request.QueryString["MaND"] != null)
            {

                DataTable dt = tv.LayDoiThongTin(Request.QueryString["MaND"].ToString());

                if (dt.Rows.Count <= 0)
                {
                    Response.Write(" Ten DN khong hop le");

                }
                else
                {
                    lblDoiTV.Text = dt.Rows[0]["TenDN"].ToString();
                    txtDoiHoTen.Text = dt.Rows[0]["HoTen"].ToString();
                    txtDoiDiaChi.Text = dt.Rows[0]["DiaChi"].ToString();
                    txtDoiSDT.Text = dt.Rows[0]["SDT"].ToString();
                    tv.TenDN = dt.Rows[0]["TenDN"].ToString();
                   tv.HoTen = dt.Rows[0]["HoTen"].ToString();
                   tv.DiaChi = dt.Rows[0]["DiaChi"].ToString();
                   tv.SDT = dt.Rows[0]["SDT"].ToString();

                }
            }
            else
            {
                Response.Write("TenDN khong hop le");
            }
        } 
    }
    
    protected void btnLuu_Click(object sender, EventArgs e)
    {
        tv.TenDN = Request.QueryString["MaND"].ToString();
        
        if (tv.DoiThongTin(txtDoiHoTen.Text,txtDoiDiaChi.Text,txtDoiSDT.Text) == true) 
        {
            Response.Write("TC");
            
        }
        else
        {
            Response.Write("TB");
        }
    }
    }
